package leetcode.simple._previous;

//删除单向链表的指针
public class DeleteNode {

    public ListNode deleteNode(ListNode head, int val) {
        if (head == null) return head;
        if (val == head.val) return head.next;

        ListNode _head = head.next,pre = head;
        while (_head != null) {

            if (_head.val == val) {
                pre.next = _head.next;
                break;
            }

            pre = _head;
            _head = _head.next;

        }

        return head;
    }
}
